package com.bawei.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.bawei.domain.Goods;
import com.bawei.util.HLUtils;
import com.github.pagehelper.PageInfo;

@Controller
public class GoodsController {

	@Autowired
	private ElasticsearchTemplate elasticsearchTemplate;
	
	@RequestMapping("list")
	public String list(Model model,@RequestParam(defaultValue = "1")Integer pageNum,@RequestParam(defaultValue = "3")Integer pageSize,String value) {
		
		PageInfo<Goods> info = HLUtils.findByHighLight(elasticsearchTemplate, Goods.class, pageNum, pageSize, value, "name", 3, "id", new String[] {"name","categoryName"});
		model.addAttribute("info", info);
		return "goods_list";
	}
	
}
